{include file="public/header"}

<body>
  <div class="layui-fluid">
    <div class="layui-row">
      <form action="" method="post" class="layui-form layui-form-pane">
        <div class="layui-card layui-form" lay-filter="component-form-element">
          <div class="layui-card-header">配置名</div>
          <div class="layui-card-body layui-row layui-col-space10">
            <div class="layui-col-md12">
              <input
                type="text"
                value="{$row.remark|default=''}"
                required=""
                lay-verify="required"
                autocomplete="off"
                class="layui-input"
                disabled
              />
            </div>
          </div>
        </div>
        {if !empty($row.name) && $row.name == 'intergal'}
        <div class="layui-card layui-form" lay-filter="component-form-element">
          <div class="layui-card-header">配置值</div>
          <div class="layui-card-body layui-row layui-col-space10">
            <div class="layui-col-md12">
              <input
                type="text"
                value="{$row.value|default=''}"
                required=""
                name="value"
                lay-verify="required"
                class="layui-input"
              />
            </div>
          </div>
        </div>
        {/if} {if !empty($row.name) && ($row.name == 'myus' || $row.name ==
        'irule')}
        <div class="layui-card layui-form" lay-filter="component-form-element">
          <div class="layui-card-body layui-row layui-col-space10">
            <div class="layui-col-md12">
              <textarea id="infos" name="value">
                      {if !empty($row.value)}{:htmlspecialchars_decode($row.value)}{/if}</textarea
              >
            </div>
          </div>
        </div>
        {/if}
        <div class="layui-form-item">
          <input type="hidden" value="{$row['name']|default=''}" name="name" />
          <button class="layui-btn" lay-submit="" lay-filter="add">提交</button>
        </div>
      </form>
    </div>
  </div>
  {include file="public/footer"}
  <script src="/static/leyedit/Layui-KnifeZ/layui.all.js"></script>
  <script src="/static/leyedit/ace/ace.js"></script>
  <script>
    function addtable2() {
      var i = $("#table2 tbody tr").length;
      //你要添加的html
      var html =
        "<tr>" +
        '<td><input required="" lay-verify="required" type="number" id="layui-input" class="layui-input" name="value[order][' +
        i +
        '][key]" value=""></td>' +
        '<td><input required="" lay-verify="required" type="number" id="layui-input" class="layui-input" name="value[order][' +
        i +
        '][value]" value=""></td>' +
        '<td><a class="layui-btn layui-btn-danger layui-btn-xs del" >删除</a></td></tr>';
      $(html).appendTo($("#table2 tbody:last"));
      layui.use(["form"], function () {
        $ = layui.jquery;
        var form = layui.form;
        form.render();
      });
    }
    function addtable3() {
      var i = $("#table3 tbody tr").length;
      //你要添加的html
      var html =
        "<tr>" +
        '<td><input required="" lay-verify="required" type="text" id="layui-input" class="layui-input" name="value[shop][' +
        i +
        '][key]" value=""></td>' +
        '<td><input required="" lay-verify="required" type="number" id="layui-input" class="layui-input" name="value[shop][' +
        i +
        '][value]" value=""></td>' +
        '<td><a class="layui-btn layui-btn-danger layui-btn-xs del" >删除</a></td></tr>';
      $(html).appendTo($("#table3 tbody:last"));
      layui.use(["form"], function () {
        $ = layui.jquery;
        var form = layui.form;
        form.render();
      });
    }
    function addtable4() {
      var i = $("#table4 tbody tr").length;
      //你要添加的html
      var html =
        "<tr>" +
        '<td><input required="" lay-verify="required" type="text" id="layui-input" class="layui-input" name="value[orderuser][' +
        i +
        '][key]" value=""></td>' +
        '<td><input required="" lay-verify="required" type="number" id="layui-input" class="layui-input" name="value[orderuser][' +
        i +
        '][value]" value=""></td>' +
        '<td><a class="layui-btn layui-btn-danger layui-btn-xs del" >删除</a></td></tr>';
      $(html).appendTo($("#table4 tbody:last"));
      layui.use(["form"], function () {
        $ = layui.jquery;
        var form = layui.form;
        form.render();
      });
    }
    function addtable5() {
      var i = $("#table5 tbody tr").length;
      //你要添加的html
      var html =
        "<tr>" +
        '<td><input required="" lay-verify="required" type="text" id="layui-input" class="layui-input" name="value[monethclass][' +
        i +
        '][key]" value=""></td>' +
        '<td><input required="" lay-verify="required" type="number" id="layui-input" class="layui-input" name="value[monethclass][' +
        i +
        '][value]" value=""></td>' +
        '<td><input required="" lay-verify="required" type="number" id="layui-input" class="layui-input" name="value[monethclass][' +
        i +
        '][times]" value=""></td>' +
        '<td><input required="" lay-verify="required" type="number" id="layui-input" class="layui-input" name="value[monethclass][' +
        i +
        '][min]" value=""></td>' +
        '<td><input required="" lay-verify="required" type="number" id="layui-input" class="layui-input" name="value[monethclass][' +
        i +
        '][max]" value=""></td>' +
        '<td><a class="layui-btn layui-btn-danger layui-btn-xs del" >删除</a></td></tr>';
      $(html).appendTo($("#table5 tbody:last"));
      layui.use(["form"], function () {
        $ = layui.jquery;
        var form = layui.form;
        form.render();
      });
    }
    $("body").on("click", ".del", function () {
      $(this).closest("tr").remove();
    });
    layui.use(["form", "layer", "upload", "upload", "layedit"], function () {
      $ = layui.jquery;
      var form = layui.form,
        upload = layui.upload,
        element = layui.element,
        layer = layui.layer,
        layedit = layui.layedit;
      layedit.set({
        //暴露layupload参数设置接口 --详细查看layupload参数说明
        uploadImage: {
          url: "/Base/upload_img",
          accept: "image",
          acceptMime: "image/*",
          exts: "jpg|png|gif|bmp|jpeg",
          size: "100240",
        },
        //右键删除图片/视频时的回调参数，post到后台删除服务器文件等操作，
        //传递参数：
        //图片： imgpath --图片路径
        //视频： filepath --视频路径 imgpath --封面路径
        calldel: {
          url: "/Base/upload_img",
        },
        //开发者模式 --默认为false
        devmode: false,
        //插入代码设置
        codeConfig: {
          hide: true, //是否显示编码语言选择框
          default: "javascript", //hide为true时的默认语言格式
        },

        tool: [
          "strong",
          "italic",
          "underline",
          "del",
          "|",
          "left",
          "center",
          "right",
        ],
        height: "300px",
      });
      var infos = layedit.build("infos");
      //监听提交
      form.on("submit(add)", function (data) {
        //发异步，把数据提交给php
        if (data.field.name == "myus" || data.field.name == "irule") {
          data.field.value = layedit.getContent(infos);
        }
        $.ajax({
          type: "post",
          data: data.field,
          success: function (res) {
            if (res.status == 0) {
              layer.msg(res.msg, { icon: 6, time: 1000 }, function () {
                // 获得frame索引
                var index = parent.layer.getFrameIndex(window.name);
                parent.location.reload();
                parent.layer.close(index);
              });
            } else {
              layer.msg(res.msg, { icon: 2, time: 1000 });
            }
          },
        });
        return false;
      });
    });
  </script>
</body>
